sum of list java

55

Get the SUM of integers in List JAVA -

int sum = list.stream().mapToInt(Integer::intValue).sum();

sum of list java -

double sum = 0;
for(int i = 0; i < m.size(); i++)
    sum += m.get(i);
return sum;

Comments

Submit
0 Comments